﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Model
{   
    [Serializable]
    public class WorkNode{
        private string projectName;
        private string nodeNum;
        private string nodeName;
        private DateTime sessionDate;
        private string pidList;
        private string tecDesc;
        private List<WorkNodeItem> workNodeItemList = new List<WorkNodeItem>();

        public WorkNode(){}
        public WorkNode(string projectName, string nodeNum, string nodeName, DateTime sessionDate,  string pidList, List<WorkNodeItem> workNodeItemList, string techDesc){
            this.projectName = projectName;
            this.nodeNum = nodeNum;
            this.nodeName = nodeName;
            this.sessionDate = sessionDate;
            this.pidList = pidList;
            this.workNodeItemList = workNodeItemList;
            this.tecDesc = techDesc;
        }

        public string ProjectName{
            get { return projectName; }
            set { projectName = value; }
        }

        public string NodeNum{
            get { return nodeNum; }
            set { nodeNum = value; }
        }

        public string NodeName{
            get { return nodeName; }
            set { nodeName = value; }
        }

        public DateTime SessionDate{
            get { return sessionDate; }
            set { sessionDate = value; }
        }

        public string PidList{
            get { return pidList; }
            set { pidList = value; }
        }

        public List<WorkNodeItem> WorkNodeItemList{
            get { return workNodeItemList; }
            set { workNodeItemList = value; }
        }

        public string TecDesc{
            get { return tecDesc; }
            set { tecDesc = value; }
        }

        public override bool Equals(object obj){
            if(obj != null && obj is WorkNode){
                WorkNode p = (WorkNode) obj;
                if(this.projectName == p.projectName && this.nodeName == p.nodeName && this.nodeNum == p.nodeNum
                    && this.sessionDate == p.sessionDate && this.pidList == p.pidList && this.tecDesc == p.tecDesc){
                    for (int i = 0; i < workNodeItemList.Count; i++){
                        if (workNodeItemList[i].Equals(p.workNodeItemList[i])){
                            continue;
                        }
                        else{
                            return false;
                        }
                    }
                    return true;
                }
            }
            return false;
        }
    }
}
